package com.example.gymlearning.service.impl;

import com.example.gymlearning.entity.LearningRecord;
import com.example.gymlearning.mapper.LearningRecordMapper;
import com.example.gymlearning.service.LearningRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (LearningRecord)表服务实现类
 *
 * @author makejava
 * @since 2025-10-27 21:06:13
 */
@Service("learningRecordService")
public class LearningRecordServiceImpl implements LearningRecordService {
    @Resource
    private LearningRecordMapper learningRecordMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public LearningRecord queryById(Long id) {
        return this.learningRecordMapper.queryById(id);
    }

      /**
     * 新增数据
     *
     * @param learningRecord 实例对象
     * @return 实例对象
     */
    @Override
    public LearningRecord insert(LearningRecord learningRecord) {
        this.learningRecordMapper.insert(learningRecord);
        return learningRecord;
    }

    /**
     * 修改数据
     *
     * @param learningRecord 实例对象
     * @return 实例对象
     */
    @Override
    public LearningRecord update(LearningRecord learningRecord) {
        this.learningRecordMapper.update(learningRecord);
        return this.queryById(learningRecord.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.learningRecordMapper.deleteById(id) > 0;
    }
}
